#include <iostream>
#include <string>
#include <thread>

using namespace std;

int main(int argc, char const *argv[])
{
    cout << "main thread start:";
    // 获取当前线程ID
    cout << this_thread::get_id() << endl;

    // 创建并启动子线程
    thread th([]()
              {
                  cout << "in thread:";
                  cout << this_thread::get_id() << endl;
                  this_thread::sleep_for(1s);
                  cout << "in thread exit" << endl;
              });

    // 释放CPU资源，睡眠100ms、1s
    this_thread::sleep_for(100ms);

    // 等待子线程结束
    th.join();

    cout << "main thread exit!" << endl;

    return 0;
}
